/*
 * Copyright 2022,2023 NXP.
 *
 * NXP Confidential. This software is owned or controlled by NXP and may only be
 * used strictly in accordance with the applicable license terms. By expressly
 * accepting such terms or by downloading,installing, activating and/or otherwise
 * using the software, you are agreeing that you have read,and that you agree to
 * comply with and are bound by, such license terms. If you do not agree to be
 * bound by the applicable license terms, then you may not retain, install, activate
 * or otherwise use the software.
 *
 */

#ifndef UWBRADAR_PD_H
#define UWBRADAR_PD_H

#include "uwbradar_common.h"
#include <stdlib.h>
#include <stdbool.h>

/** \addtogroup uwbradar_apis
 *
 * @{ */

/**
 * @brief  Structure lists out Presence Detection callback information.
 */

typedef struct _pd_Measurement_callback
{
    /** Time determined by CIR idx in Secs */
    uint8_t time;
    /** Presence is detected 1-Detected ,0-Not Detected */
    bool presenceDetected;
    /** Distance to the presence in cm */
    float presenceDistance;
    /** The relation between the signal magnitude at the distance and the calculated noise */
    float snrValue;
} pd_Measurement_callback_t;

/**
 * @brief callback support for Presence Detection which calls from the internal Radar Lib .
 * \param pPdInfo Pointer to pd_Measurement_callback_t struct, contains the presence related params
 */
typedef void (*UwbRadarApi_Presence_Measurement_Callback_t)(pd_Measurement_callback_t *pPdInfo);


/**
 * @brief API to Set Presence detection configuration for Radar Lib.
 *        This API takes Presence detection configurations and callback as a inputs and callback can be used to Notifies the result via callback.
 *
 * \param[in] detection_range_min the minimum distance for presence detection in centimeter.
 * \param[in] detection_range_max the maximum distance for presence detection in centimeter.
 *            detection_range_max <= TapsToCM(MAX_CIR_TAPS),  MAX_CIR_TAPS = 128.
 *            i.e TapsToCM(MAX_CIR_TAPS) ((numTaps - 6) * 15) internal to Radar Lib.
 * \param[in] detection_sensitivity threshold for peak selection.
 * \param[in] radar_frame_repeat_interval Radar Frame Repetition Interval time between CIRs in ms.
 * \param[in] reaction_time Reaction time in ms in which the device should react.
 * \param[in] settling_time pPdCback the callback to Notify the Results.
 * \param[in]  pPdCback pPdCback the callback to Notify the Results.
 *
 * \retval  #kStatus_Success  if all params are valid
 * \retval  #kStatus_Invalid  if all params are less than 0 and callback is Null
 * \retval  #kStatus_Fail     otherwise
 */
uint8_t UwbRadarApi_SetPresence_Configs(float detection_range_min,
    float detection_range_max,
    float detection_sensitivity,
    uint8_t radar_frame_repeat_interval,
    uint8_t reaction_time,
    uint8_t settling_time,
    UwbRadarApi_Presence_Measurement_Callback_t *pPdCback);

/** @} */ /* @addtogroup uwbradar_apis */
#endif //UWBRADAR_PD_H